//
//  Leaf.m
//  SSE
//
//  Created by Matt Roman on 10/30/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "Leaf.h"


@implementation Leaf

- (id)initLeafWithPoint:(Point3f)pt ID:(int)num
{
	[super initNodeWithID:num];
	vertex = pt;
	direction = 0;
	parentLeaf = nil;
	LfArray = [[NSMutableArray alloc] init];
	return self;
}

- (void) setPoint:(Point3f)pt
{
	vertex = pt;
}

- (Point3f) getPoint
{
	return vertex;
}

- (Point3f *) getPtrPoint
{
	return &vertex;
}

- (void) addLeafWithID:(int)num Point:(Point3f)pt VertexNumber:(int)vtn Distance:(double)d Direction:(double)dir Parent:(Leaf *)lf
{
	Leaf *leaf = [[Leaf alloc] initLeafWithPoint:pt ID:num];
	[leaf setVertexNumber:vtn];
	[leaf setDistance:d];
	[leaf setDirection:dir];
	[leaf setParentLeaf:lf];
	[LfArray addObject:leaf];
	[leaf release];
}

- (NSMutableArray *) getLfArray
{
	return LfArray;
}

- (double) direction
{
	return direction;
}

- (Leaf *) parentLeaf
{
	return parentLeaf;
}

- (void) setDirection:(double)d
{
	direction = d;
}

- (void) setParentLeaf:(Leaf *)lf
{
	parentLeaf = lf;
}

- (NSComparisonResult)compareAngle:(Leaf *)aLeaf
{
	if(direction < [aLeaf direction])return NSOrderedAscending;
	else if(direction > [aLeaf direction])return NSOrderedDescending;
	else return NSOrderedSame;
}
	
- (void) dealloc
{
	parentLeaf = nil;
	[LfArray release];
	[super dealloc];
}

@end
